package com.itany.corejava.code11_内部类;

import com.itany.corejava.code11_内部类.SomeOuter.SomeInner;

/**
 * @author 石小俊
 * @version 1.0
 * @date 2023年03月20日 16:16
 */
public class Test03_静态内部类 {
    public static void main(String[] args) {
        // 定义静态内部类时,无需创建外部类对象
        // 有两种方式进行定义
        // 方式一:将 外部类.内部类 当做一个类名
        // SomeOuter.SomeInner in = new SomeOuter.SomeInner();
        // 方式二:手动导包,手动通过import关键字导包
        SomeInner in = new SomeInner();
        in.print();
    }
}

class SomeOuter {
    private static String name = "admin";
    private int age = 18;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void show() {
        System.out.println("*************外部类的方法*************");
        SomeInner in = new SomeInner();
        System.out.println(in.name);
        System.out.println(in.gender);
    }

    static class SomeInner {
        private String name = "jack";
        private String gender = "男";

        public void print() {
            System.out.println("*************静态内部类方法*************");
            System.out.println(name);
            System.out.println(SomeOuter.name);
            SomeOuter out = new SomeOuter();
            System.out.println(out.age);
            out.show();
        }
    }

}
